package com.wing.productionPlan.model.entity;

import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.*;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.socket.sockjs.transport.TransportType;

/**
 * 生产计划
 *
 * @author
 */
@EqualsAndHashCode(callSuper = true)
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@TableName("ord_production_plan")
public class ProductionPlan extends BaseEntity<ProductionPlan> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum OrderType implements IEnum<Integer> {

        /**
         * 打样工单
         */
        temporary(0, "临时计划"),
        /**
         * 按订单
         */
        order(1,"量产订单"),

        /**
         * 成品销售
         */
        finish(2,"成品销售订单"),

        other(99,"其他计划");

        private int code;
        private String desc;

        OrderType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    public enum Status implements IEnum<Integer> {

        /**
        * 待审核
        */
        checkpending(0,"待审核"),
        /**
        * 已审核
        */
        checked(1,"已审核"),
        /**
        * 待排产
        */
        rowproduce(2,"待排产"),
        /**
        * 已排产
        */
        alreadyrowproduce(3,"已排产"),
        /**
        * 待生产
        */
        tobeproduced(4,"待生产"),
        /**
        * 生产中
        */
        inproduction(5,"生产中"),
        /**
        * 完成
        */
        accomplish(6,"完成"),
        /**
        * 作废
        */
        cancellation(7,"作废"),
        /**
         * 待确认
         */
        toconfirmed(8,"待确认"),
        /**
         * 已确认
         */
        affirm(9,"已确认");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }
    public enum PlanSource implements IEnum<Integer> {

        /**
         * 临时计划
         */
        temporary(0,"临时计划"),
        /**
         * 按订单
         */
        order(1,"量产订单"),

        /**
         * 成品销售
         */
        finish(2,"成品销售订单");

        private int code;
        private String desc;

        PlanSource(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }
    public enum SignOrNot implements IEnum<Integer> {

        /**
         * 已签约
         */
        yes(0,"已签约"),
        /**
         * 未签约
         */
        no(1,"未签约");

        private int code;
        private String desc;

        SignOrNot(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
        @JsonCreator
        public static SignOrNot jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (SignOrNot item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum PlanNature implements IEnum<Integer> {

        /**
         * 整体生产计划
         */
        entirety(0,"整体生产计划"),
        /**
         * 工序生产计划
         */
        process(1,"工序生产计划");

        private int code;
        private String desc;

        PlanNature(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }
    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 产品性质
     */
    private String productNatureName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * day
     */
    private Integer day;

    /**
     * no
     */
    private Integer no;

    /**
     * 企业编号
     */
    private String enterpriseCode;

    /**
     * 计划编号
     */
    private String code;

    /**
     * 产品类型id
     */
    private Long productTypeId;

    /**
     * 产品类型名称
     */
    private String productTypeName;

    /**
     * 客户SKU料号
     */
    private String customerSkuCode;

    /**
     * 客户SKU规格码
     */
    private String customerSkuSpec;
    /**
     * 客户sku名称
     */
    private String customerSkuName;
    /**
     * 附件
     */
    private String accessory;

    /**
     * 单位id
     */
    private Long unitId;

    /**
     * 单位名称
     */
    private String unitName;

    /**
     * 计划订单类型
     */
    private OrderType orderType;

    /**
    * 计划订单类型描述
    */
    @TableField(exist = false)
    private String orderTypeDesc;

    public String getOrderTypeDesc() {
        return orderType == null ? null : orderType.getDesc();
    }

    /**
     * 生产数量
     */
    private Integer productionQuantity;

    /**
    * 出货时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime shipmentTime;

    /**
     * 状态
     */
    private Status status;

    /**
    * 状态描述
    */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 订单id
     */
    private Long orderId;

    /**
     * 计划来源
     */
    private PlanSource planSource;

    /**
     * 计划来源描述
     */
    @TableField(exist = false)
    private String planSourceDesc;

    public String getPlanSourceDesc() {
        return planSource == null ? null : planSource.getDesc();
    }

    /**
     * 计划分类id
     */
    private Long planClassifyId;

    /**
     * 是否签约
     */
    private SignOrNot signOrNot;

    /**
     * 是否签约描述
     */
    @TableField(exist = false)
    private String signOrNotDesc;

    public String getSignOrNotDesc() {
        return signOrNot == null ? null : signOrNot.getDesc();
    }

    /**
     * 合同id
     */
    private Long contractId;

    /**
     * 计划类型id
     */
    private Long planTypeId;

    /**
     * 计划性质
     */
    private PlanNature planNature;

    /**
     * 计划性质描述
     */
    @TableField(exist = false)
    private String planNatureDesc;

    public String getPlanNatureDesc() {
        return planNature == null ? null : planNature.getDesc();
    }

    /**
     * 工序id
     */
    private Long processId;

    /**
     * 需求数量
     */
    private Integer demandQuantity;

    /**
     * 计划产出时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime outputTime;

    public enum CheckStatus implements IEnum<Integer> {
        /**
         * 审核通过
         */
        approve(0,"审核通过"),
        /**
         * 驳回
         */
        reject(1,"驳回"),
        /**
         * 待审核
         */
        toaudit(2,"待审核");

        private int code;
        private String desc;

        CheckStatus(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }
    /**
     * 审核状态
     */
    private CheckStatus checkStatus;

    /**
     * 审核状态描述
     */
    @TableField(exist = false)
    private String checkStatusDesc;

    public String getCheckStatusDesc() {
        return checkStatus == null ? null : checkStatus.getDesc();
    }
    /**
     * 审核时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime auditTime;
    /**
     * 审核描述
     */
    private String auditRemark;
    /**
     * 审核人
     */
    private String auditPerson;
    /**
     * 包装方案
     */
    private String packName;
    /**
     * 创建人电话
     */
    private String phone;
    /**
     * 订单产品id
     */
    private Long orderProId;

    /**
     * 基准书id
     */
    private Long bookId;

    /**
     * 物料id
     */
    private Long productDetailId;

    /**
     * 车间
     */
    private Long workshopId;
}
